﻿/**
 * \file FabriquePoidsMoucheCase.cs
 * \brief Classe FabriquePoidsMoucheCase
 * \author ARTUR Vincent
 * \author LAPERDRIX Pierre
 * \version 1.0
 */
namespace Implem
{
	using Interfaces;
	using System;
	using System.Collections;
	using System.Linq;
	using System.Text;

    /**
     * \class FabriquePoidsMoucheCase
     * \brief Fabrique de cases utilisant le pattern "poids-mouche"
     */
	public class FabriquePoidsMoucheCase : IFabriquePoidsMoucheCase
	{
        /*!< Singleton de la fabrique */
        public static FabriquePoidsMoucheCase INSTANCE = new FabriquePoidsMoucheCase();

        /**
         * \enum typeCase
         * \brief Enumeration des differents types de cases
         */
        private enum typeCase{
            p, /*!< Case Plaine */
            pfe, /*!< Case PlaineFer */
            pfr, /*!< Case PlaineFruit */
            d, /*!< Case Desert */
            dfe, /*!< Case DesertFer */
            dfr, /*!< Case DesertFruit */
            m, /*!< Case Montagne */
            mfe, /*!< Case MontagneFer */
            mfr /*!< Case MontagneFruit */
        }

        /*!< Hachage contenant les instances des cases (cle = typeCase , valeur = Case)*/
        private Hashtable cases;

        /**
         * \fn public FabriquePoidsMoucheCase()
         * \brief Constructeur de FabriquePoidsMoucheCase
         */
        private FabriquePoidsMoucheCase()
        {
            cases = new Hashtable();
        }

        /**
         * \fn public virtual Case getMontagne()
         * \brief Retourne une case de type Montagne
         * \return la case
         */
		public virtual Case getMontagne()
		{
            if (cases[typeCase.m] == null)
            {
                Montagne cm = new Montagne();
                cases.Add(typeCase.m, cm);
            }
            return (Montagne)cases[typeCase.m];
		}

        /**
         * \fn public virtual Case getMontagneFer()
         * \brief Retourne une case de type MontagneFer
         * \return la case
         */
        public virtual Case getMontagneFer()
        {
            if (cases[typeCase.mfe] == null)
            {
                CaseFer cmfe = new CaseFer(new Montagne());
                cases.Add(typeCase.mfe, cmfe);
            }
            return (CaseFer)cases[typeCase.mfe];
        }

        /**
         * \fn public virtual Case getMontagneFruit()
         * \brief Retourne une case de type MontagneFruit
         * \return la case
         */
        public virtual Case getMontagneFruit()
        {
            if (cases[typeCase.mfr] == null)
            {
                CaseFruit cmfr = new CaseFruit(new Montagne());
                cases.Add(typeCase.mfr, cmfr);
            }
            return (CaseFruit)cases[typeCase.mfr];
        }

        /**
         * \fn public virtual Case getPlaine()
         * \brief Retourne une case de type Plaine
         * \return la case
         */
		public virtual Case getPlaine()
		{
            if (cases[typeCase.p] == null)
            {
                Plaine cp = new Plaine();
                cases.Add(typeCase.p, cp);
            }
            return (Plaine)cases[typeCase.p];
		}

        /**
         * \fn public virtual Case getPlaineFer()
         * \brief Retourne une case de type PlaineFer
         * \return la case
         */
        public virtual Case getPlaineFer()
        {
            if (cases[typeCase.pfe] == null)
            {
                CaseFer cpfe = new CaseFer(new Plaine());
                cases.Add(typeCase.pfe, cpfe);
            }
            return (CaseFer)cases[typeCase.pfe];
        }

        /**
         * \fn public virtual Case getPlaineFruit()
         * \brief Retourne une case de type PlaineFruit
         * \return la case
         */
        public virtual Case getPlaineFruit()
        {
            if (cases[typeCase.pfr] == null)
            {
                CaseFruit cpfr = new CaseFruit(new Plaine());
                cases.Add(typeCase.pfr, cpfr);
            }
            return (CaseFruit)cases[typeCase.pfr];
        }

        /**
         * \fn public virtual Case getDesert()
         * \brief Retourne une case de type Desert
         * \return la case
         */
		public virtual Case getDesert()
        {
            if (cases[typeCase.d] == null)
            {
                Desert dm = new Desert();
                cases.Add(typeCase.d, dm);
            }
            return (Desert)cases[typeCase.d];
        }

        /**
         * \fn public virtual Case getDesertFer()
         * \brief Retourne une case de type DesertFer
         * \return la case
         */
        public virtual Case getDesertFer()
        {
            if (cases[typeCase.dfe] == null)
            {
                CaseFer cdfe = new CaseFer(new Desert());
                cases.Add(typeCase.dfe, cdfe);
            }
            return (CaseFer)cases[typeCase.dfe];
        }

        /**
         * \fn public virtual Case getDesertFruit()
         * \brief Retourne une case de type DesertFruit
         * \return la case
         */
        public virtual Case getDesertFruit()
        {
            if (cases[typeCase.dfr] == null)
            {
                CaseFruit cdfr = new CaseFruit(new Desert());
                cases.Add(typeCase.dfr, cdfr);
            }
            return (CaseFruit)cases[typeCase.dfr];
        }

	}
}

